<?php

namespace app\api\controller;

use think\Controller;
use think\Request;

class Upload  extends Controller
{

    public function  pubdata(Request $request)
    {

        $file = request()->file('file');

        if (isset($file) && !empty($file)) {

            $tempSaveFileAddress = "/uploads/temp/" . $request->param('path');
            //$this->mkdirs($tempSaveFileAddress);

            $tempSaveFileName = $request->param('name');
            $info = $file->move($tempSaveFileAddress, $tempSaveFileName);

            if ($info) {
                return true;
            } else {
                return false;
            }
        } else {
            return false;
        }
    }
    function mkdirs($a1, $mode = 0777)
    {
        if (is_dir($a1) || @mkdir($a1, $mode)) return TRUE;
        if (!$this->mkdirs(dirname($a1), $mode)) return FALSE;
        return @mkdir($a1, $mode);
    }
}
